<%@ page import="java.util.ArrayList" %>
<%@ page import="com.example.mystore.entity.Commodity" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>商品详情</title>
    <link rel="stylesheet" href="css/header.css">
    <link rel="stylesheet" href="css/footer.css">
    <style>
        .banner * { margin: 0;padding: 0}
        .banner a {text-decoration: none}
        .banner { width: 1000px;height: 520px;margin: 20px auto}
        .banner .img { width: 400px;height: 400px;border: 1px solid darkgray;display: inline-block;margin-top: 50px;}
        .banner img { width: 180px;height: 180px;margin-top: 110px;margin-left: 110px}
        .banner .info { width: 500px;height: 400px;display: inline-block;float: right;margin-top: 50px;margin-left: 30px }
        .banner .info .name { font-size: 30px;height: 50px;line-height: 50px}
        .banner .info .type { height: 30px;line-height: 30px}
        .banner .info .msg { height: 250px}
        .banner .info .btn { height: 70px}
        .banner .info .btn .price { height:70px;width:180px;background-color: deepskyblue;border: white;cursor: pointer;color: white;font-size: 20px}
        .banner .info .btn .addShopCar { height:70px;width:230px;background-color: #f8b203;border: white;cursor: pointer;color: whitesmoke;font-size: 20px}
    </style>
</head>
<body>
<header id="header">
    <div id="headerBox">
        <h1>品优购</h1>
        <a href="display.jsp">返回首页</a>
        <a href="Cart.jsp">我的购物车</a>
        <a href="">联系客服</a>
        <%if (request.getSession().getAttribute("customer")!=null){%>
        <a href="${pageContext.request.contextPath}/LogoutServlet" style="float: right;">退出登录</a>
        <%}else{%>
        <a href="login.jsp" style="float: right;">用户登录</a>
        <%}%>
        <hr>
    </div>
</header>
<div class="banner">
    <%
        Commodity commodity = null;
        if ( request.getSession().getAttribute("commodityArr") != null) {
            ArrayList<Commodity> commodityArr =
                    (ArrayList<Commodity>) request.getSession().getAttribute("commodityArr");
            int id = Integer.parseInt(request.getParameter("id"));
            for (Commodity c : commodityArr) {
                if (c.getId() == id) {
                    commodity = c;
                    break;
                }
            }
        }
            if(commodity != null){%>
    <div class="img">
        <img src="img/<%=commodity.getImg()%>" alt="">
    </div>
    <div class="info">
        <div class="name">名称:<%=commodity.getName()%></div>
        <div class="type">型号：<%=commodity.getModel()%> </div>
        <div class="msg"><%=commodity.getIntroduction()%></div>
        <div class="btn">
            <a href=""><button class="price">￥<%=commodity.getPrice()%> </button></a>
            <a href="${pageContext.request.contextPath}/toAdd?id=<%=commodity.getId()%>"><button class="addShopCar">加入购物车</button></a>
        </div>
    </div>
</div>
<%}%>
<footer id="footer">
    <div id="footerBox">
        <div class="">
            <a  href="">
                关于我们
            </a>
            |
            <a href="">
                联系我们
            </a>
            |
            <a href="">
                人才招聘
            </a>
            |
            <a  href="">
                商家入驻
            </a>
            |
            <a href="">
                广告服务
            </a>
            |
            <a  href="">
                友情链接
            </a>
            |
            <a  href="">
                销售联盟
            </a>
            |
            <a href="" >
                商家社区
            </a>
            |
            <a href="" >
                捐款公益
            </a>
        </div>
        <div class="">
            1107841498@qqcom&nbsp;©&nbsp;&nbsp;&nbsp;&nbsp;版权归<a href="">@清秋</a>所有
        </div>
    </div>
</footer>
</body>
</html>
